using System.Drawing;
using TouchSmart.Drawing;
using TouchSmart.Gestures;

namespace TouchSmart.Widgets
{
    public class ListItem : Widget
    {
        private readonly IImage _leftBar;
        private readonly IImage _rightGreenBar;

        private readonly string _text;
        private readonly Font _font;
        private readonly Brush _brush;

        public ListItem(string text) : base(Point.Empty, new Size(230, 45))
        {
            this._text = text;
            this._font = new Font("Arial", 15.0f, FontStyle.Bold);
            this._brush = new SolidBrush(Color.White);

            var imageFactory = Locator.GetService<IImageFactory>();
            this._leftBar = imageFactory.CreateImage("LeftBar.png");
            this._rightGreenBar = imageFactory.CreateImage("RightBarGreen.png");
        }

        public override void Draw(Graphics g)
        {
            g.DrawImageAlphaChannel(this._leftBar, Location.X, Location.Y);
            g.DrawImageAlphaChannel(this._rightGreenBar, Location.X + 172, Location.Y);
            g.DrawString(this._text, this._font, this._brush, this.Location.X + 16, this.Location.Y + 10);
        }

        public override void OnMovement(MovementEventArgs e)
        {
            this.Location = new Point(Location.X, Location.Y + e.Vector.Y);
        }
    }
}